home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
3_0
/
CUTILSLI
/
UTILITYL
/
RAND.C
< prev
next >
Wrap
Text File
|
1987-11-10
|
1KB
|
35 lines
/*********************************************
* Filename: Rand.c
* Purpose: Random Number Generator
* Authors: Robert E. Neville
* Date: November 10, 1987
* Functions: Rand().
* Version 1.0a
* Copyright 1987 Hummingbird Graphics
*********************************************/
extern long randSeed; /* Extern global from Mactraps */
/**********************************
* Function: Rand(div)
* Purpose: Generate a random #
* Passed: unsigned int - div
* Returned: int num
***********************************/
int Rand(div)
unsigned int div;
{
static int done = 0; /* Static so we only do this once */
int num; /* the number */
if (!done) /* we haven't done this before */
{
GetDateTime(&randSeed); /* store number of seconds in randSeed */
done = 1; /* don't do it again */
}
num = Random(); /* get a random number */
return(num % div); /* in range 0 - div */
} /* end of Rand */
/*********** End of File ***********/